package com.foreveross.vo;

import java.sql.Timestamp;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.springframework.format.annotation.DateTimeFormat;

/**
 * Express entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "express", catalog = "hrtenement")
public class Express implements java.io.Serializable {

	private String id;
	private HouseUser houseUser;
	private String expressNo;
	private String name;
	private String address;
	private String telephone;
	private Integer type;
	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
	private Date applayTime;
	private Integer status;
	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
	private Date finishTime;
	private String mailingAddress;
	private Integer expressType;
	private String message;
	private ExpressCompany expressCompany;
	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
	private Date sendDate;
	private String houseName;
	private String sendAddress;
	private String packageDescription;
	private String houseUserName;
	private String houseUserTelephone;
 

	// Constructors  

	/** default constructor */
	public Express() {
	}

	/** minimal constructor */
	public Express(String id) {
		this.id = id;
	}

	/** full constructor */
	public Express(String id, HouseUser houseUser, String expressNo,
			String name, String address, String telephone, Integer type,
			Date applayTime, Integer status, Date finishTime) {
		this.id = id;
		this.houseUser = houseUser;
		this.expressNo = expressNo;
		this.name = name;
		this.address = address;
		this.telephone = telephone;
		this.type = type;
		this.applayTime = applayTime;
		this.status = status;
		this.finishTime = finishTime;
	}

	// Property accessors
	@Id
	@GenericGenerator(name = "idGenerator", strategy = "uuid")
	@GeneratedValue(generator = "idGenerator")
	@Column(name = "id", unique = true, nullable = false, length = 32)
	public String getId() {
		return this.id;
	}

	public void setId(String id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "user_id")
	@NotFound(action = NotFoundAction.IGNORE)
	public HouseUser getHouseUser() {
		return this.houseUser;
	}

	public void setHouseUser(HouseUser houseUser) {
		this.houseUser = houseUser;
	}

	@Column(name = "express_no")
	public String getExpressNo() {
		return this.expressNo;
	}

	public void setExpressNo(String expressNo) {
		this.expressNo = expressNo;
	}

	@Column(name = "name")
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "address")
	public String getAddress() {
		return this.address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	@Column(name = "telephone")
	public String getTelephone() {
		return this.telephone;
	}

	public void setTelephone(String telephone) {
		this.telephone = telephone;
	}

	@Column(name = "type")
	public Integer getType() {
		return this.type;
	}

	public void setType(Integer type) {
		this.type = type;
	}

	@Column(name = "applay_time")
	public Date getApplayTime() {
		return this.applayTime;
	}

	public void setApplayTime(Date applayTime) {
		this.applayTime = applayTime;
	}

	@Column(name = "status")
	public Integer getStatus() {
		return this.status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	@Column(name = "finish_time")
	public Date getFinishTime() {
		return this.finishTime;
	}

	public void setFinishTime(Date finishTime) {
		this.finishTime = finishTime;
	}


	public String getMailingAddress() {
		return mailingAddress;
	}

	public void setMailingAddress(String mailingAddress) {
		this.mailingAddress = mailingAddress;
	}

	public Integer getExpressType() {
		return expressType;
	}

	public void setExpressType(Integer expressType) {
		this.expressType = expressType;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "express_company_id")
	@NotFound(action = NotFoundAction.IGNORE)
	public ExpressCompany getExpressCompany() {
		return expressCompany;
	}

	public void setExpressCompany(ExpressCompany expressCompany) {
		this.expressCompany = expressCompany;
	}

	public Date getSendDate() {
		return sendDate;
	}

	public void setSendDate(Date sendDate) {
		this.sendDate = sendDate;
	}

	@Transient
	public String getHouseName() {
		if (houseUser != null&&houseUser.getHrHouses()!=null)
			return houseUser.getHrHouses().getName();
		return houseName;
	}

	public void setHouseName(String houseName) {
		this.houseName = houseName;
	}

	@Column(name = "send_address")
	public String getSendAddress() {
		return sendAddress;
	}

	public void setSendAddress(String sendAddress) {
		this.sendAddress = sendAddress;
	}

	@Column(name = "package_description")
	public String getPackageDescription() {
		return packageDescription;
	}

	public void setPackageDescription(String packageDescription) {
		this.packageDescription = packageDescription;
	}

	@Transient
	public String getHouseUserName() {
		if(houseUser!=null)
			return houseUser.getName();
		return houseUserName;
	}

	public void setHouseUserName(String houseUserName) {
		this.houseUserName = houseUserName;
	}

	@Transient
	public String getHouseUserTelephone() {
		if (houseUser != null)
			return houseUser.getTelephone();
		return houseUserTelephone;
	}

	public void setHouseUserTelephone(String houseUserTelephone) {
		this.houseUserTelephone = houseUserTelephone;
	}
	
}